﻿using Abp.EntityFramework;
using Laboratory.Entities;
using Laboratory.EntityFramework;
using Laboratory.EntityFramework.Repositories;
using Laboratory.IRepositories;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Laboratory.Repositories
{
    public class ProjectRepository : LaboratoryRepositoryBase<Project, Guid>, IProjectRepository
    {

        public ProjectRepository(IDbContextProvider<LaboratoryDbContext> dbContextProvider) : base(dbContextProvider)
        {

        }
        public List<Project> GetCitiesWithProvince(string name)
        {
            var query = GetAll();//GetAll()返回一个IQueryable<T>，我们可以通过它来查询
            var query2 = Context.Project.AsQueryable();//也可以直接使用EF的DbContext对象
            var query3 = Table.AsQueryable();//另一种选择：直接使用Table属性代替"Context.Cities"，都是一样的。
            if (!string.IsNullOrEmpty(name))
            {
                query = query.Where(c => c.Name == name);
            }
            return query.ToList();
        }

    }
}
